package com.eve.springcloud.controller;

import java.util.concurrent.TimeUnit;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.eve.springcloud.service.DeptService;

@RestController
public class DeptController {

	@Resource
	private DeptService deptService;
	
	@GetMapping(value = "/dept/get/{id}")
	public String get(@PathVariable("id") Long id) {
		try {
			TimeUnit.MILLISECONDS.sleep(500);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return deptService.payment(id);
	}
	
	@GetMapping(value = "/dept/timeout/{id}")
	public String timeoutTest(@PathVariable("id") Long id) {
		return deptService.paymentTimeout(id);
	}
	
	// 服务熔断 20200518
	@GetMapping(value = "/dept/circuitBreaker/{id}")
	public String circuitBreakerTest(@PathVariable("id") Long id) {
		return deptService.circuitBreakerDept(id);
	}
	
	
	
}
